package dto.app;

import models.application.*;
import models.pubobj.*;
import models.user.*;

/**
 * User: yeh
 * Date: 1/29/13
 * Time: 6:05 PM
 * For:  wilddragon
 */
public class PublicAppInfoDto extends AppInfoDto {

    public Long id;

    public String ownerUser;

    public AniAppClassification appClassification;

    public AniObjectType type;

    public AniObjectState state;

    public String appName;

    public String description;

    public byte[] icon;

    public PublicAppInfoDto(AniUser curUser, AniApp oneAppDao, Long id, String ownerUser, AniAppClassification appClassification, AniObjectType type, AniObjectState state, String appName, String description, byte[] icon, Boolean isInstalled) {
        super(
                oneAppDao,
                curUser,
                isInstalled
        );
        this.id = id;
        this.ownerUser = ownerUser;
        this.appClassification = appClassification;
        this.type = type;
        this.state = state;
        this.appName = appName;
        this.description = description;
        this.icon = icon;
    }
    public static PublicAppInfoDto generateFromDao(AniApp oneApp, Boolean isInstalled, AniUser oneUser){
        return new PublicAppInfoDto(
                oneUser,
                oneApp,
                oneApp.id,
                oneApp.ownerUser.screenName == null ? oneApp.ownerUser.email : oneApp.ownerUser.screenName,
                oneApp.appClassification,
                oneApp.type,
                oneApp.state,
                oneApp.appName,
                oneApp.description,
                oneApp.icon,
                isInstalled
        );
    }
}